import { HttpServer, WsServer } from "tsrpc";
import { ecs } from "../../core/ecs/ECS";
import { HallModelComp } from "./model/HallModel";
import { HallServiceStartComp, HallServiceStartSystem } from "./system/HallServiceStartSys";
import { JoinRoomServiceComp, JoinRoomServiceSystem } from "./system/JoinRoomServiceSystem";


/**
 * 账号服务提供以下服务：
 * 1.提供账号创建
 * 2.提供账号验证
 * 3.提供sso解析账号信息
 * 4.提供生成sso
 */


@ecs.register(`HallService`)
export class HallService extends ecs.Entity {
    HallModel!: HallModelComp;
    JoinRoomServiceComp!: JoinRoomServiceComp;

    protected init() {
        this.addComponents<ecs.Comp>(
            HallModelComp);
    }


    start() {
        this.add(HallServiceStartComp);
    }

    joinRoomService(call:any) {
        this.add(JoinRoomServiceComp).call = call;
    }
    
}

export class EcsHallSystem extends ecs.System {
    constructor() {
        super();

        this.add(new HallServiceStartSystem());
        this.add(new JoinRoomServiceSystem());
    }
}

export class HallServiceRootSystem extends ecs.RootSystem {
    constructor() {
        super();
        this.add(new EcsHallSystem());
    }
}